package com.zc.io;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.junit.Test;

public class HashMapTest {
	@Test
	public void test(){
		LinkedHashMap<Integer, String> map = new  LinkedHashMap<Integer, String>();
		map.put(1, "a");
		map.put(2, "b");
		map.put(3, "c");
		map.put(4, "d");
		Set set = map.keySet();
		Iterator iter = set.iterator();
		while(iter.hasNext()){
			Integer key = (Integer) iter.next();
			String value = (String) map.get(key);
			System.out.println(key+":"+value);
		}
	}
	@Test
	public void test1(){
		Map<Integer, String> map = new  LinkedHashMap<Integer, String>();
		map.put(1, "a");
		map.put(2, "b");
		map.put(3, "c");
		map.put(4, "d");
		Set<Entry<Integer, String>> set = map.entrySet();
		Iterator<Entry<Integer, String>> iter = set.iterator();
		while(iter.hasNext()){
			Entry<?, ?> entery =  (Entry<?, ?>) iter.next();
		
			System.out.println(	entery.getKey()+":"+entery.getValue());
			
		}
	}
}
